package com.ice.work.moment.socket.config;

import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.ice.work.moment.socket.call.CheckTask;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import java.util.TimerTask;
import java.util.concurrent.*;

/**
 * @Description 启动线程消费
 * @Author DELL
 * @Create 2019-06-26
 * @Since 1.0.0
 */
@Configuration
public class ThreadConfig {
    @Bean
    public ExecutorService threadPool() {
        ThreadFactory threadFactory = new ThreadFactoryBuilder().build();
        ExecutorService executorService = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(1024), threadFactory, new ThreadPoolExecutor.AbortPolicy());
        return executorService;
    }
}
